Repository navigation
Reject explicit tails in Kernel.destructure/2 - #16145
lukaszsamson wants to merge 2 commits into
Conversation
Assisted-by: Codex:gpt-6.2-sol
|
I don't believe this was ever intended to match on cons patterns and we should raise instead. |
The docs https://elixir.hexdocs.pm/Kernel.html#destructure/2 make me believe cons operator was intended to be supported
|
|
I believe the intention there was to say things like |
I agree. Maybe we should raise in this case? destructure([a | b], [1, 2, 3]) # [1, [2, 3]]
destructure([a, b, c, d | e], [1, 2, 3]) # ArgumentError |
|
Let's just raise if we have a tail on the left-side at compile-time! Same check as today, except it raises! |
Assisted-by: Codex:gpt-6.2-sol
Done |
Kernel.destructure/2used to silently discard the remainder when the left-hand list had an explicit tail. It now raisesArgumentErrorat compile time for patterns such as[head | tail]. Each element in the list can still be any match pattern.